set(FAISS_TEST_SRCS
  ../../thirdparty/knowherefaiss/tests/test_omp_threads.cpp
  ../../thirdparty/knowherefaiss/tests/test_heap.cpp
  ../../thirdparty/knowherefaiss/tests/test_partitioning.cpp
  ../../thirdparty/knowherefaiss/tests/test_simdlib.cpp
  ../../thirdparty/knowherefaiss/tests/test_approx_topk.cpp
  ../../thirdparty/knowherefaiss/tests/test_code_distance.cpp
  ../../thirdparty/knowherefaiss/tests/test_cppcontrib_uintreader.cpp
  ../../thirdparty/knowherefaiss/tests/test_distances_simd.cpp
  ../../thirdparty/knowherefaiss/tests/test_hnsw.cpp
  ../../thirdparty/knowherefaiss/tests/test_binary_flat.cpp
  ../../thirdparty/knowherefaiss/tests/test_cppcontrib_sa_decode.cpp
  ../../thirdparty/knowherefaiss/tests/test_ondisk_ivf.cpp
  ../../thirdparty/knowherefaiss/tests/test_pq_encoding.cpp
  ../../thirdparty/knowherefaiss/tests/test_RCQ_cropping.cpp
  ../../thirdparty/knowherefaiss/tests/test_ivfpq_codec.cpp
  ../../thirdparty/knowherefaiss/tests/test_ivfpq_indexing.cpp
  ../../thirdparty/knowherefaiss/tests/test_merge.cpp
  ../../thirdparty/knowherefaiss/tests/test_threaded_index.cpp
  ../../thirdparty/knowherefaiss/tests/test_pairs_decoding.cpp
  ../../thirdparty/knowherefaiss/tests/test_dealloc_invlists.cpp
  ../../thirdparty/knowherefaiss/tests/test_params_override.cpp
  ../../thirdparty/knowherefaiss/tests/test_sliding_ivf.cpp
  ../../thirdparty/knowherefaiss/tests/test_transfer_invlists.cpp
  ../../thirdparty/knowherefaiss/tests/test_distances_if.cpp
  ../../thirdparty/knowherefaiss/tests/test_fastscan_perf.cpp
  ../../thirdparty/knowherefaiss/tests/test_ivf_index.cpp
  ../../thirdparty/knowherefaiss/tests/test_disable_pq_sdc_tables.cpp
  ../../thirdparty/knowherefaiss/tests/test_common_ivf_empty_index.cpp
  ../../thirdparty/knowherefaiss/tests/test_callback.cpp
  )

find_package(GTest REQUIRED)

if(__X86_64)
  add_executable(faiss_tests ${FAISS_TEST_SRCS})

  add_dependencies(faiss_tests knowherefaiss)
  target_compile_options(
    faiss_tests
    PRIVATE $<$<COMPILE_LANGUAGE:CXX>:
            -msse4.2
            -mavx2
            -mfma
            -mf16c
            -Wno-sign-compare
            -Wno-unused-variable
            -Wno-reorder
            -Wno-unused-local-typedefs
            -Wno-unused-function
            -Wno-strict-aliasing>)
  target_link_libraries(
    faiss_tests PUBLIC knowherefaiss knowhere GTest::gtest GTest::gtest_main)
  target_compile_definitions(faiss_tests PRIVATE FINTEGER=int)
endif()

if(__AARCH64)
  add_executable(faiss_tests ${FAISS_TEST_SRCS})
  target_compile_options(
    faiss_tests
    PRIVATE $<$<COMPILE_LANGUAGE:CXX>:
            -Wno-sign-compare
            -Wno-unused-variable
            -Wno-reorder
            -Wno-unused-local-typedefs
            -Wno-unused-function
            -Wno-strict-aliasing>)

  add_dependencies(faiss_tests knowherefaiss)
  target_link_libraries(faiss_tests PUBLIC knowherefaiss knowhere GTest::gtest GTest::gtest_main)
  target_compile_definitions(faiss_tests PRIVATE FINTEGER=int)
endif()
